<template >
  <basiccard :header_nav="header_nav">
    <el-row>
      <el-col :span="6">
        <el-input placeholder="请输入内容" v-model="search_Order" class="input-with-select">
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </el-col>
    </el-row>
    <!-- 数据表格 -->
    <el-table :data="orderList" stripe border style="width: 100%">
      <el-table-column type="index" width="60"></el-table-column>
      <el-table-column prop="order_number" label="订单编号" width="260"></el-table-column>
      <el-table-column prop="order_price" label="订单价格" width="100"></el-table-column>
      <el-table-column label="是否付款" width="80">
        <template slot-scope="scope">
          <el-tag type="danger" v-if="scope.row.pay_status==='0'">未付款</el-tag>
          <el-tag type="success" v-else>已付款</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="is_send" label="是否发货" width="80"></el-table-column>
      <el-table-column label="下单时间" width="230">
        <template slot-scope="scope">{{scope.row.create_time | dateFormat}}</template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            icon="el-icon-edit"
            size="mini"
            @click="editOrder(scope.row.order_id)"
          ></el-button>
          <el-button type="success" icon="el-icon-location-outline" size="mini"
          @click="LogOrder"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="params.pagenum"
      :page-sizes="[3, 5, 8, 10]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
    <!-- 编辑提示框 -->
    <el-dialog title="修改地址" :visible.sync="addressVisible" width="50%" @close="addressClose">
      <el-form :model="addressForm" :rules="addressRules" ref="addressFormRef" label-width="100px">
        <el-form-item label="省市区/县" prop="address1">
          <el-cascader
            expand-trigger="hover"
            :options="address"
            v-model="addressForm.address1"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="address2">
          <el-input v-model="addressForm.address2"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addressVisible = false">取 消</el-button>
        <el-button type="primary" @click="addressVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 物流提示框 -->
    <el-dialog
  title="物流信息"
  :visible.sync="LogVisible"
  width="50%"
  ref="LogRef"
  @close="Logclose"
 >
 <div class="block">
  <el-timeline :reverse="false">
    <el-timeline-item :timestamp="item.ftime" placement="top" v-for="(item,i) in LogInfo" :key="i">
      <el-card>
        <h4 v-if="i==(LogInfo.length-1)">当前进度</h4>
        <p>{{item.context}}</p>
      </el-card>
    </el-timeline-item>
  </el-timeline>
</div>
  <span slot="footer" class="dialog-footer">
    <el-button @click="LogVisible = false">取 消</el-button>
    <el-button type="primary" @click="LogVisible = false">确 定</el-button>
  </span>
</el-dialog>
  </basiccard>
</template>
<script>
import address from "./citydata.js";
export default {
  name: "Order",
  data() {
    return {
      header_nav: {
        path: "/welecome",
        rolesMge: "角色管理",
        rolesList: "角色列表"
      },
      //   省市数据
      address: address,
      search_Order: "",

      // 级联规则
      //   查询参数
      params: {
        query: "",
        pagenum: 1,
        pagesize: 5
      },
      //   当前页面
      total: 1,

      orderList: [], //   订单数据列表
      addressVisible: false,
    //   物流
    LogVisible:false,
    // 物流信息
    LogInfo:[],
      //   地址表单
      addressForm: {
        //   选中的数组
        address1: [],
        address2: ""
      },
      // 规则对象
      addressRules: {
        address1: [
          { required: true, message: "请选择省市区名称", trigger: "blur" }
        ],
        address2: [
          {
            required: true,
            message: "请输入详细",
            trigger: "blur"
          }
        ]
      }
    };
  },
  methods: {
    async getOrderList() {
      const { data: res } = await this.$http.get("orders", {
        params: this.params
      });
      if (res.meta.status !== 200) {
        this.$message.error("获取订单列表失败");
      }
      (this.orderList = res.data.goods), (this.total = res.data.total);
      console.log(this.orderList);
    },
    // 页面长度改变
    handleSizeChange(val) {
      this.params.pagesize = val;
      this.getOrderList();
    },
    // 当前页改变
    handleCurrentChange(val) {
      this.params.pagenum = val;
      this.getOrderList();
    },
    // 编辑订单
    editOrder(val) {
      this.addressVisible = true;
    },
    handleChange() {},
    // 编辑框关闭
    addressClose() {
      this.$refs.addressFormRef.resetFields();
      //    this.addressForm.address1 = []
      //    this.addressForm.address2 = ''
    },
    // 物流
    async LogOrder() {
           this.LogVisible = true
           const {data:res} =await this.$http.get(`/kuaidi/1106975712662`)
           if(res.meta.status!==200) return this.$message.error('获取物流信息失败')
           this.LogInfo = res.data
           console.log(this.LogInfo);
           
    },
    Logclose() {
        this.LogInfo = []
    }

  },
  created() {
    this.getOrderList();
  }
};
</script>
<style lang="scss" scoped>
.el-cascader {
  width: 100%;
}
</style>